package com.ccntec.test;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ccntec.spark.core.model.SystemCode;

public class DataServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		
		Map<String, String> dataMap = new HashMap<String, String>();
		dataMap.put("map选项1", "1");
		dataMap.put("map选项2", "2");
		dataMap.put("map选项3", "3");
		dataMap.put("map选项4", "4");
		request.setAttribute("dataMap", dataMap);
		
		List<SystemCode> codeList= new ArrayList<SystemCode>();
		for (int i = 0; i < 5; i++) {
			SystemCode code = new SystemCode();
			/////////////////////
			code.setCodeName("name"+i);
			code.setCodeVaule("value"+i);
			code.setCodeNo("no"+i);
			code.setCodeState("state"+i);
			code.setCodeType("type"+i);
			codeList.add(code);
		}
		request.setAttribute("codeList", codeList);
		System.out.println(codeList);
		System.out.println(dataMap);
		request.getRequestDispatcher("/test/form/input/input.jsp").forward(request, response);
		out.flush();
		out.close();
	}

}
